Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Add mkldnn OP for slice #13730

Merged
merged 11 commits into from
Jan 16, 2019
Merged

Add mkldnn OP for slice #13730

merged 11 commits into from
Jan 16, 2019

Conversation

huangzhiyuan
Copy link
Contributor

@huangzhiyuan huangzhiyuan commented Dec 26, 2018

Description

Add mkldnn implement for slice OP

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

test_slice has passed

@pengzhao-intel , @ZhennanQin , @TaoLv

@pengzhao-intel
Copy link
Contributor

@huangzhiyuan please verify the performance in #12303 and other tests from your local.

@TaoLv TaoLv added Operator MKLDNN pr-awaiting-review PR is waiting for code review labels Dec 26, 2018
src/operator/nn/mkldnn/mkldnn_slice-inl.h Outdated Show resolved Hide resolved
src/operator/tensor/matrix_op-inl.h Outdated Show resolved Hide resolved
src/operator/tensor/matrix_op-inl.h Outdated Show resolved Hide resolved
src/operator/tensor/matrix_op-inl.h Outdated Show resolved Hide resolved
Copy link
Contributor

@pengzhao-intel pengzhao-intel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific test case for this change is added?

offsets[i] = s;
}
auto in_mem = in.GetMKLDNNData();
auto in_mem_pd = in_mem->get_primitive_desc();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please merge in_mem and in_mem_pd into one line as out_mem_pd in case the in_mem doesn't use in here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just for the overall code style, I can also modify it if you insist.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the "overall code style"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have merge im_mem and im_mem_pd into one line in the new commit.

src/operator/nn/mkldnn/mkldnn_slice.cc Show resolved Hide resolved
src/operator/tensor/matrix_op-inl.h Outdated Show resolved Hide resolved
src/operator/tensor/matrix_op.cc Show resolved Hide resolved
@huangzhiyuan
Copy link
Contributor Author

@pengzhao-intel No specific test case for this change should be added, the current test case is enough to cover. Thanks for your review :)

Copy link
Contributor

@pengzhao-intel pengzhao-intel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the improvements!

LGTM

offsets[i] = s;
}
auto in_mem = in.GetMKLDNNData();
auto in_mem_pd = in_mem->get_primitive_desc();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the "overall code style"?

static MX_THREAD_LOCAL std::unordered_map<MKLDNNSliceSignature, MKLDNNSliceFwd, OpHash> fwds;
#endif
MKLDNNSliceSignature key(param);
key.AddSign(in_data);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to have is_train and out_data into the key?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In_data is enough for the key to cache. And I have put is_train and out_data into the key in new commit.


if (in_stype == kDefaultStorage) {
#if MXNET_USE_MKLDNN == 1
if (dev_mask == Context::kCPU && MKLDNNEnvSet() && SupportMKLDNNSlice(param)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@huangzhiyuan
Copy link
Contributor Author

The CI failure seem to same with #13833, and fix patch [#13841] is WIP. @TaoLv please help to review again :)

Copy link
Member

@TaoLv TaoLv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix. Let's wait for CI passing.

@TaoLv TaoLv merged commit 2616275 into apache:master Jan 16, 2019
@TaoLv
Copy link
Member

TaoLv commented Jan 16, 2019

Closes #12303 .

@huangzhiyuan huangzhiyuan deleted the mkldnn-slice branch January 17, 2019 01:32
stephenrawls pushed a commit to stephenrawls/incubator-mxnet that referenced this pull request Feb 16, 2019
* add mkldnn slice

* fix lint

* fix lint

* mv SliceEx to matrix_op.cc

* fix lint

* optimize dispatch_mode

* retrigger ci

* fix indent
haohuanw pushed a commit to haohuanw/incubator-mxnet that referenced this pull request Jun 23, 2019
* add mkldnn slice

* fix lint

* fix lint

* mv SliceEx to matrix_op.cc

* fix lint

* optimize dispatch_mode

* retrigger ci

* fix indent
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
MKLDNN Operator pr-awaiting-review PR is waiting for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants